﻿using SharpKit.JavaScript;

namespace SharpKit.Onx
{
    /// <summary>
    /// 'device' object is the top-level object and is used to access all other on{X} client components. Logs can be viewed on a 'Logs' page of the on{X} web portal.
    /// https://www.onx.ms/#apiPage/device
    /// </summary>
    [JsType(Mode = JsMode.Prototype, Export = false)]
    public class Device
    {
        //No way to new this up
        private Device()
        { }

        #region Supported Components
        /// <summary>
        /// opens URLs and launch native browser app
        /// </summary>
        [JsProperty(NativeField = true, Name = "browser")]
        public Browser Browser{ get { return null; } }

        /// <summary>
        /// display notifications and message boxes
        /// </summary>
        [JsProperty(NativeField = true, Name = "notifications")]
        public Notifications Notifications { get { return null; } }

        /// <summary>
        /// query and run installed applications
        /// </summary>
        [JsProperty(NativeField = true, Name = "applications")]
        public Applications Applications { get { return null; } }

        /// <summary>
        /// schedule scripts executions at a later time
        /// </summary>
        [JsProperty(NativeField = true, Name = "scheduler")]
        public Scheduler Scheduler { get { return null; } }

        /// <summary>
        /// register/query for device screen state changes
        /// </summary>
        [JsProperty(NativeField = true, Name="screen")]
        public Screen Screen { get { return null; } }

        /// <summary>
        /// register/query for telephony state changes
        /// </summary>
        [JsProperty(NativeField = true, Name = "telephony")]
        public Telephony Telephony { get { return null; } }

        /// <summary>
        /// trigger code based on entry/exit to/from user-defined geographical regions
        /// </summary>
        [JsProperty(NativeField = true, Name = "regions")]
        public Regions Regions { get { return null; } }

        /// <summary>
        /// register/query for battery state changes
        /// </summary>
        [JsProperty(NativeField = true, Name = "battery")]        
        public Battery Battery { get { return null; } }

        /// <summary>
        /// register/query for availability of WiFi and mobile networks
        /// </summary>
        [JsProperty(NativeField = true, Name = "network")]
        public Network Network { get { return null; } }

        /// <summary>
        /// use it to receive location updates from the various location providers (GPS, network, etc.)
        /// </summary>
        [JsProperty(NativeField = true, Name = "location")]
        public Location Location { get { return null; } }

        /// <summary>
        /// register for changes in the detected mode of transport (walking/running/vehicle/etc.)
        /// </summary>
        [JsProperty(NativeField = true, Name = "modeOfTransport")]        
        public ModeOfTransport ModeOfTransport { get { return null; } }

        /// <summary>
        /// provides persistent storage for script's private data that is not visible to other scripts
        /// </summary>
        [JsProperty(NativeField = true, Name = "localStorage")]
        public LocalStorage LocalStorage { get { return null; } }

        /// <summary>
        /// provides persistent storage for sharing information across several scripts
        /// </summary>
        [JsProperty(NativeField = true, Name = "sharedStorage")]
        public SharedStorage SharedStorage { get { return null; } }

        /// <summary>
        /// send emails and SMS messages and trigger code based on arrival of messages
        /// </summary>
        [JsProperty(NativeField = true, Name = "messaging")]
        public Messaging Messaging { get { return null; } }
        #endregion

        #region HttpClient interface
        /// <summary>
        /// Sends an http request This method should be invoked from JavaScript.
        /// </summary>
        /// <param name="args">the ajax object</param>
        /// <param name="onSuccess">A callback to be called when the http response is returned with no error. Default is null.</param>
        /// <param name="onError">A callback to be called when the http fails with an error. Default is null.</param>
        /// <returns>the request object, it can be used to cancel pending ajax operation.</returns>
        [JsMethod(Name = "ajax")]
        public HttpScriptClientPromise Ajax(AjaxArguments args, AjaxSuccessCallback onSuccess = null, AjaxErrorCallback onError = null)
        { return null; }
        #endregion
    }
}
